home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 227_01 / bios.c < prev    next >
Text File  |  1988-02-07  |  3KB  |  145 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3.  
  4. #define NOLLHINC
  5.  
  6. #include "bios.h"
  7. #include "graphics.h"
  8.  
  9. int gpage;                                  /* current graphics page */
  10.  
  11. #ifdef USEVOID
  12. void
  13. #endif
  14. setmode(mode)
  15. int mode;
  16. /**
  17. * name          setmode
  18. *
  19. * synopsis      setmode(mode);
  20. *               int mode           video-mode
  21. *
  22. * description   This routine switches to the given video-mode.
  23. *               For valid values see the BIOS video mode tables.
  24. **/
  25. {
  26. union REGS regs;
  27.  
  28. regs.h.ah = 0;     /* action: set mode */
  29. regs.h.al = mode;
  30. int86(0x10, ®s, ®s);
  31. gpage = 0;         /* currently graphics page zero! */
  32. }
  33.  
  34.  
  35. #ifdef USEVOID
  36. void
  37. #endif
  38. setpixel(x, y, color)
  39. int x, y;
  40. int color;
  41. /**
  42. * name          setpixel
  43. *
  44. * synopsis      setpixel(x, y, color);
  45. *               int x, y
  46. *               int color
  47. *
  48. * description   This routine is used to set the pixel (x, y) to the
  49. *               specified color. For valid colorvalues see the BIOS-tables.
  50. **/
  51. {
  52. union REGS regs;
  53.  
  54. regs.h.ah = 0xc;     /* action: set pixel */
  55. regs.h.al = color;
  56. regs.h.bh = gpage;
  57. regs.x.cx = x;
  58. regs.x.dx = y;
  59. int86(0x10, ®s, ®s);
  60. }
  61.  
  62.  
  63. getpixel(x, y)
  64. int x, y;
  65. /**
  66. * name          getpixel
  67. *
  68. * synopsis      getpixel(x, y);
  69. *               int x, y
  70. *
  71. * description   This routine reads the color of the specified pixel.
  72. *               The color is returned as function return value.
  73. **/
  74. {
  75. union REGS regs;
  76.  
  77. regs.h.ah = 0xd;     /* action: get pixel */
  78. regs.h.bh = gpage;
  79. regs.x.cx = x;
  80. regs.x.dx = y;
  81. int86(0x10, ®s, ®s);
  82. return((int) regs.h.al);
  83. }
  84.  
  85.  
  86. #ifdef USEVOID
  87. void
  88. #endif
  89. selpage(pgnr)
  90. int pgnr;
  91. /**
  92. * name          selpage
  93. *
  94. * synopsis      selpage(pgnr);
  95. *               int pgnr
  96. *
  97. * description   This routine allows the selection of the active video page.
  98. *               Note that the number of available pages depends on the
  99. *               video mode.
  100. **/
  101. {
  102. union REGS regs;
  103.  
  104. regs.h.ah = 5;       /* action: select active page */
  105. regs.h.al = pgnr;
  106. int86(0x10, ®s, ®s);
  107. gpage = pgnr;
  108. }
  109.  
  110.  
  111. #ifdef USEVOID
  112. void
  113. #endif
  114. clrgraph(dummy)
  115. int dummy;
  116. /**
  117. * name          clrgraph
  118. *
  119. * synopsis      clrgraph(dummy)
  120. *               int dummy   no meaning, only for compitibility with herc-lib
  121. *
  122. * description   This routine clears the current graphics-page. Because there
  123. *               is no "graphics clear screen", it first get the actuall video
  124. *               mode and then switches back to that mode. The mode switch
  125. *               includes a clear-screen.
  126. *               The current version of this routine clears always video page
  127. *               zero - if it is the current page or not!
  128. *               The dummy argument is included only for compatibility with the
  129. *               hercules-modules.
  130. **/
  131. {
  132. union REGS regs;
  133.  
  134. regs.h.ah = 0x0f;        /* action: read current video mode */
  135. int86(0x10, ®s, ®s);
  136. regs.h.ah = 0x00;        /* action: set video mode (and clear screen!) */
  137. int86(0x10, ®s, ®s);
  138. if(gpage)                /* current page other than page zero? */
  139.   {                      /* Yes, must switch! */
  140.   regs.h.ah = 0x05;      /* action: select vido page */
  141.   regs.h.al = gpage;     /* libraries page */
  142.   int86(0x10, ®s, ®s);
  143.   }
  144. }
  145.